package com.dykj.fireFighting.server.socialUnit.devHis.service.impl;

import com.dykj.fireFighting.api.socialUnit.devHis.entity.DevHisFire;
import com.dykj.fireFighting.api.socialUnit.devHis.entity.SuspectedFire;
import com.dykj.fireFighting.api.socialUnit.devHis.service.IDevHisFireService;
import com.dykj.fireFighting.common.core.service.impl.BaseServiceImpl;
import com.dykj.fireFighting.common.core.utils.DateUtil;
import com.dykj.fireFighting.server.socialUnit.devHis.mapper.DevHisFireMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import static org.apache.commons.lang3.StringUtils.split;

/**
 * 自动报警设备运行记录接口实现
 *
 * @Author fgc
 * @Date  2021-06-15 16:52:12
 */
@Slf4j
@DubboService
@Transactional(rollbackFor = Exception.class)
public class DevHisFireServiceImpl extends BaseServiceImpl<DevHisFireMapper, DevHisFire> implements IDevHisFireService {
    @Autowired
    private DevHisFireMapper devHisFireMapper;

    @Override
    public int updateSuspectedFire(SuspectedFire suspectedFire) {
        return devHisFireMapper.updateSuspectedFireByid(suspectedFire);
    }

    @Override
    public SuspectedFire getById(String id) {
        return devHisFireMapper.getById(id);
    }

    @Override
    public List<DevHisFire> queryByIds(String ids) {
        ids = StringUtils.deleteWhitespace(ids.replace("[","").replace("]",""));
        String[] split = ids.split(",");
        String tableName="dev_his_"+ DateUtil.getYearWeek();
        List<DevHisFire> devHisFires = devHisFireMapper.queryByIds(tableName,split);
        return devHisFires;
    }
}
